#ifndef __CMT_SPI3_H
#define __CMT_SPI3_H

#include "stdint.h"

__inline void cmt_spi3_delay(void);
__inline void cmt_spi3_delay_us(void);

#define CMT_CSB_PORT			GPIOA
#define CMT_CSB_PIN				GPIO_PIN_15//寄存器片选脚

#define CMT_FCSB_PORT			GPIOB
#define CMT_FCSB_PIN			GPIO_PIN_5//FIFO片选脚

#define CMT_CLK_PORT			GPIOB
#define CMT_CLK_PIN				GPIO_PIN_3//时钟脚

#define CMT_SDIO_PORT			GPIOB
#define CMT_SDIO_PIN			GPIO_PIN_4//输入输出脚

#define CMT_INT1_PORT			GPIOB
#define CMT_INT1_PIN			GPIO_PIN_6//中断脚1

#define CMT_INT2_PORT			GPIOB
#define CMT_INT2_PIN			GPIO_PIN_7//中断脚2

#define read_int1()				GPIO_ReadInputDataBit(CMT_INT1_PORT, CMT_INT1_PIN)
#define read_int2()				GPIO_ReadInputDataBit(CMT_INT2_PORT, CMT_INT2_PIN)

void cmt_spi3_init(void);

void cmt_spi3_send(uint8_t data8);
uint8_t cmt_spi3_recv(void);

void cmt_spi3_write(uint8_t addr, uint8_t dat);
void cmt_spi3_read(uint8_t addr, uint8_t* p_dat);

void cmt_spi3_write_fifo(const uint8_t* p_buf, uint16_t len);
void cmt_spi3_read_fifo(uint8_t* p_buf, uint16_t len);

#endif
